package com.zyf.project.capchain.api;

import com.zyf.project.capchain.listener.result.impl.Result;
import com.zyf.project.capchain.model.User;
import com.zyf.project.capchain.service.WxUserInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Zhou Yifan
 */
@Slf4j
@RestController
@RequestMapping("/user/api")
@RequiredArgsConstructor
public class WxLoginAPI {

    private final WxUserInfoService wxUserInfoService;

    @PostMapping("/wxlogin")
    public Result<User> wxlogin(@RequestParam("code") String code) {
        return wxUserInfoService.authorizeLogin(code);
    }

}
